package Presentacion.academico;

import clases.general.Ciudad;
import clases.incio.ButtonEditor;
import clases.incio.ButtonRenderer;
import global.Dialogos;
import global.Iconos;
import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

public final class dlgFamiliar extends javax.swing.JDialog {

    public static DefaultTableModel modeloFamiliar;
    private String[] fila;
    private Iconos ico = new Iconos();

    /**
     * Creates new form dlgFamiliar
     *
     * @param parent
     * @param modal
     */
    public dlgFamiliar(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setResizable(false);
        setTitle("REGISTRO DE FAMILIARES");
        setLocationRelativeTo(this);
        iconos();
        frmConsultaFamiliar.objFamiliar.comboCiudad(cbociudadf);
        frmConsultaFamiliar.objFamiliar.listarOcupacion(cboocupacion);
        armarmodeloFamilia();
        limpiarFamiliar();
    }
    
     private void iconos() {
        btnnuevo.setIcon(ico.getNuevo());
        btnguardar.setIcon(ico.getGuardar());
        btnsalir.setIcon(ico.getSalir());
        btnactualizar.setIcon(ico.getActualizar());
    }

    private void OcultarColumnasTable(JTable tbl, int columna) {
        tbl.getColumnModel().getColumn(columna).setMaxWidth(0);
        tbl.getColumnModel().getColumn(columna).setMinWidth(0);
        tbl.getTableHeader().getColumnModel().getColumn(columna).setMaxWidth(0);
        tbl.getTableHeader().getColumnModel().getColumn(columna).setMinWidth(0);
    }

    public Boolean TextoaBoleano(javax.swing.JTable tabla, int fila, int columna) {
        return "SI".equals(tabla.getValueAt(fila, columna).toString());
    }

    public void armarmodeloFamilia() {
        modeloFamiliar = new DefaultTableModel() {
            @Override
            public boolean isCellEditable(int fila, int columna) {
                return columna == 13;
            }
        };
        tblfamiliar.removeAll();
        tblfamiliar.setModel(modeloFamiliar);
        modeloFamiliar.addColumn("CEDULA");
        modeloFamiliar.addColumn("NOMBRES");
        modeloFamiliar.addColumn("APELLIDOS");
        modeloFamiliar.addColumn("TELEFONO");
        modeloFamiliar.addColumn("Direccion");
        modeloFamiliar.addColumn("Ciudad");
        modeloFamiliar.addColumn("Lugar Trabajo");
        modeloFamiliar.addColumn("Ocupacion");
        modeloFamiliar.addColumn("Correo");
        modeloFamiliar.addColumn("Hijos");
        modeloFamiliar.addColumn("PARENTEZCO");
        modeloFamiliar.addColumn("REPRESENTANTE");
        modeloFamiliar.addColumn("FACTURA");
        modeloFamiliar.addColumn("QUITAR");
        DefaultTableCellRenderer centrar = new DefaultTableCellRenderer();
        centrar.setHorizontalAlignment(SwingConstants.CENTER);
        tblfamiliar.getColumnModel().getColumn(11).setCellRenderer(centrar);
        tblfamiliar.getColumnModel().getColumn(12).setCellRenderer(centrar);

        OcultarColumnasTable(tblfamiliar, 3);
        OcultarColumnasTable(tblfamiliar, 4);
        OcultarColumnasTable(tblfamiliar, 5);
        OcultarColumnasTable(tblfamiliar, 6);
        OcultarColumnasTable(tblfamiliar, 7);
        OcultarColumnasTable(tblfamiliar, 8);
        OcultarColumnasTable(tblfamiliar, 9);
        // OcultarColumnasTable(tblfamiliar, 12);
        TableColumn columna = new TableColumn();

        columna = tblfamiliar.getColumnModel().getColumn(13);
        columna.setPreferredWidth(25);
        columna = tblfamiliar.getColumnModel().getColumn(11);
        columna.setPreferredWidth(70);
        columna = tblfamiliar.getColumnModel().getColumn(0);
        columna.setPreferredWidth(45);
        columna = tblfamiliar.getColumnModel().getColumn(10);
        columna.setPreferredWidth(50);
        columna = tblfamiliar.getColumnModel().getColumn(1);
        columna.setPreferredWidth(95);
        columna = tblfamiliar.getColumnModel().getColumn(2);
        columna.setPreferredWidth(95);
    }

    private void adFamiliar() {
        fila = new String[13];
        fila[0] = txtcedulaf.getText();
        fila[1] = txtnombresf.getText();
        fila[2] = txtapellidof.getText();
        fila[3] = txttelefonof.getText();
        fila[4] = txtdireccionf.getText().toUpperCase();
        fila[5] = cbociudadf.getSelectedItem().toString();
        fila[6] = txtlugartrabajo.getText();
        fila[7] = cboocupacion.getSelectedItem().toString();
        fila[8] = txtmail.getText().toLowerCase();
        fila[9] = cbohijos.getSelectedItem().toString();
        fila[10] = cboParentezco.getSelectedItem().toString();
        fila[11] = cborepresentante.getSelectedItem().toString();
        fila[12] = cbofactura.getSelectedItem().toString();
        tblfamiliar.getColumnModel().getColumn(13).setCellRenderer(new ButtonRenderer());
        tblfamiliar.getColumnModel().getColumn(13).setCellEditor(
                new ButtonEditor(new JCheckBox(), modeloFamiliar, tblfamiliar));

        modeloFamiliar.addRow(fila);
        limpiarFamiliar();
    }

    private void agregarFamiliar() {
        if (txtcedula.getText().equals("")) {
                Dialogos.Error("Por favor selecione al alumno...");
                this.btnbuscar.requestFocus();
            } else if (verificarDatoTabla(txtcedulaf.getText()) == true) {
                Dialogos.Error("Este familiar ya esta agregado al alumno");
            } else if (frmConsultaFamiliar.objFamiliar.ExistenciaFamiliarAlumno(txtcedula.getText(), txtcedulaf.getText()) == true) {
                Dialogos.Error("Este familiar ya esta agregado al alumno");
            } else {
                adFamiliar();
            }    
    }

    public static boolean verificarDatoTabla(String cedula) {
        for (int i = 0; i < modeloFamiliar.getRowCount(); i++) {
            if (modeloFamiliar.getValueAt(i, 0).equals(cedula)) {
                return true;
            }

        }
        return false;
    }

    public boolean verificar(String cedula) {
        for (int i = 0; i < modeloFamiliar.getRowCount(); i++) {
            if (modeloFamiliar.getValueAt(i, 0).equals(cedula)) {
                return true;
            }

        }
        return false;
    }

    public static void llenardatosFamiliar() {
        txtcedulaf.setText(frmConsultaFamiliar.objFamiliar.getCedulaRuc());
        txtnombresf.setText(frmConsultaFamiliar.objFamiliar.getNombre());
        txtapellidof.setText(frmConsultaFamiliar.objFamiliar.getApellido());
        txtdireccionf.setText(frmConsultaFamiliar.objFamiliar.getDireccion());
        txttelefonof.setText(frmConsultaFamiliar.objFamiliar.getTelefono());
        cbociudadf.setSelectedItem(frmConsultaFamiliar.objFamiliar.getCiudad());
        cboocupacion.setSelectedItem(frmConsultaFamiliar.objFamiliar.getOcupacion());
        txtmail.setText(frmConsultaFamiliar.objFamiliar.getMail());
        txtlugartrabajo.setText(frmConsultaFamiliar.objFamiliar.getLugartrabajo());
        cbohijos.setSelectedItem(String.valueOf(frmConsultaFamiliar.objFamiliar.getHijos()));
        cboParentezco.setSelectedItem(frmConsultaFamiliar.objFamiliar.getParentezco());
        cborepresentante.setSelectedItem(frmConsultaFamiliar.objFamiliar.getRepresentante());
        cbofactura.setSelectedItem(frmConsultaFamiliar.objFamiliar.getFactura());
    }

    private void llenarTablaFamiliar(int fila) {
        if (tblfamiliar.getRowCount() != 0) {
            txtcedulaf.setText(modeloFamiliar.getValueAt(fila, 0).toString());
            txtnombresf.setText(modeloFamiliar.getValueAt(fila, 1).toString());
            txtapellidof.setText(modeloFamiliar.getValueAt(fila, 2).toString());
            txttelefonof.setText(modeloFamiliar.getValueAt(fila, 3).toString());
            txtdireccionf.setText(modeloFamiliar.getValueAt(fila, 4).toString());
            cbociudadf.setSelectedItem(modeloFamiliar.getValueAt(fila, 5).toString());
            cboocupacion.setSelectedItem(modeloFamiliar.getValueAt(fila, 7).toString());
            txtlugartrabajo.setText(modeloFamiliar.getValueAt(fila, 6).toString());
            txtmail.setText(modeloFamiliar.getValueAt(fila, 8).toString());
            cbohijos.setSelectedItem(modeloFamiliar.getValueAt(fila, 9).toString());
            cboParentezco.setSelectedItem(modeloFamiliar.getValueAt(fila, 10).toString());
            cborepresentante.setSelectedItem(modeloFamiliar.getValueAt(fila, 11).toString());
            cbofactura.setSelectedItem(modeloFamiliar.getValueAt(fila, 12).toString());
        }
    }

    public void limpiarFamiliar() {
        visiblidad(true);
       
        txtapellidof.setText("");
        txtcedulaf.setText("");
        txtdireccionf.setText("");
        txtlugartrabajo.setText("");
        cboocupacion.setSelectedIndex(0);
        txttelefonof.setText("");
        txtnombresf.setText("");
        txtmail.setText("");
        cboParentezco.setSelectedIndex(0);
        cbociudadf.setSelectedIndex(0);
        cbohijos.setSelectedIndex(0);
        cborepresentante.setSelectedIndex(0);
        cbofactura.setSelectedIndex(0);
        txtcedulaf.requestFocus();
    }

    public void visiblidad(boolean visibilidad) {
        if (visibilidad != true) {
            btnactualizar.setVisible(true);
            btnguardar.setVisible(false);
        } else {
            btnactualizar.setVisible(false);
            btnguardar.setVisible(true);
        }
    }

    private boolean Valadicaion() {
        if ("".equals(txtcedulaf.getText())) {
            Dialogos.FaltaCampo("Cedula");
            txtcedulaf.requestFocus();
            return false;
        } else if (global.Validaciones.validarCedula(txtcedulaf.getText()) == false) {
            Dialogos.Error("Cedula incorrecta");
            txtcedulaf.requestFocus();
            return false;

        } else if ("".equals(txtnombresf.getText())) {
            Dialogos.FaltaCampo("Nombres");
            txtnombresf.requestFocus();
            return false;
        } else if ("".equals(txtapellidof.getText())) {
            Dialogos.FaltaCampo("Apellidos");
            txtapellidof.requestFocus();
            return false;
        } else if ("".equals(txttelefonof.getText())) {
            Dialogos.FaltaCampo("Telefono");
            txttelefonof.requestFocus();
            return false;
        } else if ("".equals(txtmail.getText())) {
            Dialogos.FaltaCampo("Correo");
            txtmail.requestFocus();
            return false;
        } else if ("--Seleccione--".equals(cbociudadf.getSelectedItem())) {
            Dialogos.FaltaCampo("Ciudad");
            cbociudadf.requestFocus();
            return false;
        } else if ("".equals(txtdireccionf.getText())) {
            Dialogos.FaltaCampo("Direccion");
            txtdireccionf.requestFocus();
            return false;
        } else if ("--Seleccione--".equals(cboocupacion.getSelectedItem())) {
            Dialogos.FaltaCampo("Ocupacion");
            cboocupacion.requestFocus();
            return false;
        } else if ("".equals(txtlugartrabajo.getText())) {
            Dialogos.FaltaCampo("Lugar Trabajo");
            txtlugartrabajo.requestFocus();
            return false;
        } else if ("--Seleccione--".equals(cbohijos.getSelectedItem())) {
            Dialogos.FaltaCampo("Numero Hijos");
            cbohijos.requestFocus();
            return false;
        } else if ("--Seleccione--".equals(cboParentezco.getSelectedItem())) {
            Dialogos.FaltaCampo("Parentezco");
            cboParentezco.requestFocus();
            return false;
        } else if ("--Seleccione--".equals(cborepresentante.getSelectedItem())) {
            Dialogos.FaltaCampo("Representante");
            cborepresentante.requestFocus();
            return false;
        } else if ("--Seleccione--".equals(cbofactura.getSelectedItem())) {
            Dialogos.FaltaCampo("Factura");
            cbofactura.requestFocus();
            return false;
        } else {
            return true;
        }
    }
    
    private void limpiarTodo(){
        this.limpiarFamiliar();
             armarmodeloFamilia();
             txtcedula.setText("");
        txtalumno.setText("");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PanelFamiliares = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        txtcedulaf = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        txtnombresf = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtlugartrabajo = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtapellidof = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        cbohijos = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        cboParentezco = new javax.swing.JComboBox();
        cborepresentante = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        txttelefonof = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        cbociudadf = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblfamiliar = new javax.swing.JTable();
        btnagregarFamiliar = new javax.swing.JButton();
        cboocupacion = new javax.swing.JComboBox();
        jLabel27 = new javax.swing.JLabel();
        cbofactura = new javax.swing.JComboBox();
        jLabel29 = new javax.swing.JLabel();
        txtmail = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtdireccionf = new javax.swing.JTextArea();
        btnciudad = new javax.swing.JButton();
        btnocupacion = new javax.swing.JButton();
        btnbuscarPersonal = new javax.swing.JButton();
        jToolBar4 = new javax.swing.JToolBar();
        btnnuevo = new javax.swing.JButton();
        btnguardar = new javax.swing.JButton();
        btnactualizar = new javax.swing.JButton();
        btnsalir = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        txtcedula = new javax.swing.JTextField();
        btnbuscar = new javax.swing.JButton();
        txtalumno = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        PanelFamiliares.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Familiar", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        jLabel19.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel19.setText("CEDULA");

        txtcedulaf.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtcedulafKeyTyped(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("OCUPACIÓN");

        jLabel20.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel20.setText("NOMBRES");

        txtnombresf.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtnombresfKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtnombresfKeyTyped(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("LUGAR TRABAJO");

        txtlugartrabajo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtlugartrabajoKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtlugartrabajoKeyTyped(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel9.setText("APELLIDOS");

        txtapellidof.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtapellidofKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtapellidofKeyTyped(evt);
            }
        });

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel12.setText("NÚMERO HIJOS");

        cbohijos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Seleccione--", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel14.setText("PARENTEZCO");

        cboParentezco.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Seleccione--", "PADRE", "MADRE", "HERMANO(A)", "TIO(A)", "PRIMO(A)", "ABUELO(A)", "OTRO" }));

        cborepresentante.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Seleccione--", "SI", "NO" }));

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel16.setText("REPRESENTANTE");

        txttelefonof.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txttelefonofKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txttelefonofKeyTyped(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel13.setText("TELEFONO");

        jLabel17.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel17.setText("DIRECCIÓN");

        jLabel23.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel23.setText("CIUDAD");

        tblfamiliar.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblfamiliar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblfamiliarMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tblfamiliar);

        btnagregarFamiliar.setText("Agregar");
        btnagregarFamiliar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnagregarFamiliarActionPerformed(evt);
            }
        });

        cboocupacion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Seleccione--", "ESTUDIANTE", "SECRETARIA", "AMA DE CASA", "INGENIERO", "ARQUITECTO" }));

        jLabel27.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel27.setText("FACTURA");

        cbofactura.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Seleccione--", "SI", "NO" }));

        jLabel29.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel29.setText("CORREO");

        txtdireccionf.setColumns(20);
        txtdireccionf.setRows(5);
        jScrollPane2.setViewportView(txtdireccionf);

        btnciudad.setText("+");
        btnciudad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnciudadActionPerformed(evt);
            }
        });

        btnocupacion.setText("+");
        btnocupacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnocupacionActionPerformed(evt);
            }
        });

        btnbuscarPersonal.setBackground(new java.awt.Color(255, 255, 255));
        btnbuscarPersonal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/acciones/buscar.png"))); // NOI18N
        btnbuscarPersonal.setFocusable(false);
        btnbuscarPersonal.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnbuscarPersonal.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnbuscarPersonal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnbuscarPersonalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PanelFamiliaresLayout = new javax.swing.GroupLayout(PanelFamiliares);
        PanelFamiliares.setLayout(PanelFamiliaresLayout);
        PanelFamiliaresLayout.setHorizontalGroup(
            PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane1)
                    .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                        .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel13)
                                    .addComponent(jLabel9)
                                    .addComponent(jLabel29))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txttelefonof, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtapellidof, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtmail, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel17)
                                    .addComponent(jLabel23))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                                        .addComponent(cbociudadf, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(btnciudad))
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel20)
                                    .addComponent(jLabel19))
                                .addGap(18, 18, 18)
                                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                                        .addComponent(txtcedulaf, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(btnbuscarPersonal, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(txtnombresf, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(118, 118, 118)
                        .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel4)
                                .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.LEADING))
                            .addComponent(jLabel2)
                            .addComponent(jLabel27))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btnagregarFamiliar)
                            .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                                .addComponent(cboocupacion, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnocupacion))
                            .addComponent(txtlugartrabajo, javax.swing.GroupLayout.PREFERRED_SIZE, 293, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbofactura, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cborepresentante, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cboParentezco, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbohijos, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        PanelFamiliaresLayout.setVerticalGroup(
            PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelFamiliaresLayout.createSequentialGroup()
                .addGap(13, 13, 13)
                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel19)
                        .addComponent(txtcedulaf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2)
                        .addComponent(cboocupacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnocupacion))
                    .addComponent(btnbuscarPersonal, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23)
                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(jLabel4)
                    .addComponent(txtlugartrabajo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtnombresf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(25, 25, 25)
                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel12)
                    .addComponent(cbohijos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtapellidof, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(25, 25, 25)
                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelFamiliaresLayout.createSequentialGroup()
                        .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14)
                            .addComponent(cboParentezco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txttelefonof, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(45, 45, 45))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cborepresentante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel16)
                        .addComponent(jLabel29)
                        .addComponent(txtmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(24, 24, 24)
                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(cbociudadf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel27)
                    .addComponent(cbofactura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnciudad))
                .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(PanelFamiliaresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel17)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(PanelFamiliaresLayout.createSequentialGroup()
                        .addGap(54, 54, 54)
                        .addComponent(btnagregarFamiliar, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jToolBar4.setBorder(null);
        jToolBar4.setFloatable(false);
        jToolBar4.setBorderPainted(false);

        btnnuevo.setText("Nuevo");
        btnnuevo.setFocusable(false);
        btnnuevo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnnuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnnuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnnuevoActionPerformed(evt);
            }
        });
        jToolBar4.add(btnnuevo);

        btnguardar.setText("Guardar");
        btnguardar.setFocusable(false);
        btnguardar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnguardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnguardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnguardarActionPerformed(evt);
            }
        });
        jToolBar4.add(btnguardar);

        btnactualizar.setText("Actualizar");
        btnactualizar.setFocusable(false);
        btnactualizar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnactualizar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnactualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnactualizarActionPerformed(evt);
            }
        });
        jToolBar4.add(btnactualizar);

        btnsalir.setText("Salir");
        btnsalir.setFocusable(false);
        btnsalir.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnsalir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnsalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnsalirActionPerformed(evt);
            }
        });
        jToolBar4.add(btnsalir);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Alumno", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        jLabel21.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel21.setText("CEDULA");

        txtcedula.setEditable(false);

        btnbuscar.setBackground(new java.awt.Color(255, 255, 255));
        btnbuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/buscar.png"))); // NOI18N
        btnbuscar.setFocusable(false);
        btnbuscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnbuscar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnbuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnbuscarActionPerformed(evt);
            }
        });

        txtalumno.setEditable(false);

        jLabel22.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel22.setText("ALUMNO");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel21)
                .addGap(30, 30, 30)
                .addComponent(txtcedula, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnbuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel22)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtalumno, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(22, 22, 22))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(btnbuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel21)
                            .addComponent(txtcedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtalumno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel22))))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jToolBar4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 909, Short.MAX_VALUE)
                    .addComponent(PanelFamiliares, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jToolBar4, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(PanelFamiliares, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtcedulafKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtcedulafKeyTyped
        global.Validaciones.soloNumeros(evt, txtcedulaf, 10);
    }//GEN-LAST:event_txtcedulafKeyTyped

    private void txtnombresfKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtnombresfKeyReleased
        global.Validaciones.convertirMayuscula(txtnombresf);
    }//GEN-LAST:event_txtnombresfKeyReleased

    private void txtnombresfKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtnombresfKeyTyped
        global.Validaciones.soloLetras(evt, txtnombresf);
    }//GEN-LAST:event_txtnombresfKeyTyped

    private void txtlugartrabajoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtlugartrabajoKeyReleased
        global.Validaciones.convertirMayuscula(txtlugartrabajo);
    }//GEN-LAST:event_txtlugartrabajoKeyReleased

    private void txtlugartrabajoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtlugartrabajoKeyTyped
        global.Validaciones.numerosLetras(evt, txtlugartrabajo);
    }//GEN-LAST:event_txtlugartrabajoKeyTyped

    private void txtapellidofKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtapellidofKeyReleased
        global.Validaciones.convertirMayuscula(txtapellidof);
    }//GEN-LAST:event_txtapellidofKeyReleased

    private void txtapellidofKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtapellidofKeyTyped
        global.Validaciones.soloLetras(evt, txtapellidof);
    }//GEN-LAST:event_txtapellidofKeyTyped

    private void txttelefonofKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txttelefonofKeyReleased
        global.Validaciones.soloNumeros(evt, txtnombresf, 10);
    }//GEN-LAST:event_txttelefonofKeyReleased

    private void txttelefonofKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txttelefonofKeyTyped
        global.Validaciones.soloNumeros(evt, txttelefonof, 10);
    }//GEN-LAST:event_txttelefonofKeyTyped

    private void tblfamiliarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblfamiliarMouseClicked
        if (evt.getClickCount() == 2) {
            llenarTablaFamiliar(tblfamiliar.getSelectedRow());
            modeloFamiliar.removeRow(tblfamiliar.getSelectedRow());
        }
    }//GEN-LAST:event_tblfamiliarMouseClicked

    private void btnagregarFamiliarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnagregarFamiliarActionPerformed
        if (Valadicaion() == true) {
            agregarFamiliar();
        }
    }//GEN-LAST:event_btnagregarFamiliarActionPerformed

    private void btnbuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnbuscarActionPerformed
        dlgConsultaMatricula alumno = new dlgConsultaMatricula(null, true);
        alumno.setVisible(true);
    }//GEN-LAST:event_btnbuscarActionPerformed

    private void btnnuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnnuevoActionPerformed
       
        limpiarTodo();     
    }//GEN-LAST:event_btnnuevoActionPerformed

    private void btnsalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnsalirActionPerformed
        dispose();
        limpiarFamiliar();
    }//GEN-LAST:event_btnsalirActionPerformed

    private void btnciudadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnciudadActionPerformed
        String ciudad = "";
        ciudad = global.Dialogos.mostrarDialogoconTexto("AGREGAR CIUDAD", null);
        if (ciudad != null && !"".equals(ciudad)) {
            Ciudad objCiudad = new Ciudad();
            objCiudad.setNombreCiudad(ciudad.toUpperCase());
            if (objCiudad.guardarCiudad() == true) {
                cbociudadf.addItem(ciudad.toUpperCase());
            }
        }
    }//GEN-LAST:event_btnciudadActionPerformed

    private void btnactualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnactualizarActionPerformed
        if (Valadicaion() == true) {
            //matricula.dlgMatriculacion.Actulizar();
            dispose();
        }
    }//GEN-LAST:event_btnactualizarActionPerformed

    private void btnocupacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnocupacionActionPerformed
        String ocupacion = "";
        ocupacion = global.Dialogos.mostrarDialogoconTexto("AGREGAR OCUPACIÓN", null);
        if (ocupacion != null && !"".equals(ocupacion)) {
            cboocupacion.addItem(ocupacion.toUpperCase());
        }
    }//GEN-LAST:event_btnocupacionActionPerformed

    private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed
        int n = 0;
        if (this.tblfamiliar.getRowCount() == 0) {
            Dialogos.Error("No ha ingresado ningun familiar");
            return;
        } else {
            
                frmConsultaFamiliar.objFamiliar.setCedulaAlumno(txtcedula.getText());
                for (int i = 0; i < tblfamiliar.getRowCount(); i++) {
                    frmConsultaFamiliar.objFamiliar.setCedulaRuc(tblfamiliar.getValueAt(i, 0).toString());
                    frmConsultaFamiliar.objFamiliar.setNombre(tblfamiliar.getValueAt(i, 1).toString());
                    frmConsultaFamiliar.objFamiliar.setApellido(tblfamiliar.getValueAt(i, 2).toString());
                    frmConsultaFamiliar.objFamiliar.setTelefono(tblfamiliar.getValueAt(i, 3).toString());
                    frmConsultaFamiliar.objFamiliar.setDireccion(tblfamiliar.getValueAt(i, 4).toString());
                    frmConsultaFamiliar.objFamiliar.setCiudad(tblfamiliar.getValueAt(i, 5).toString());

                    frmConsultaFamiliar.objFamiliar.setCedulaFamiliar(tblfamiliar.getValueAt(i, 0).toString());
                    frmConsultaFamiliar.objFamiliar.setOcupacion(tblfamiliar.getValueAt(i, 7).toString());
                    frmConsultaFamiliar.objFamiliar.setLugartrabajo(tblfamiliar.getValueAt(i, 6).toString());
                    frmConsultaFamiliar.objFamiliar.setMail(tblfamiliar.getValueAt(i, 8).toString());
                    frmConsultaFamiliar.objFamiliar.setHijos(Integer.parseInt(tblfamiliar.getValueAt(i, 9).toString()));
                    frmConsultaFamiliar.objFamiliar.setParentezco(tblfamiliar.getValueAt(i, 10).toString());
                    frmConsultaFamiliar.objFamiliar.setRepresentante(String.valueOf(TextoaBoleano(tblfamiliar, i, 11)));
                    frmConsultaFamiliar.objFamiliar.setFactura(String.valueOf(TextoaBoleano(tblfamiliar, i, 12)));
                    if (frmConsultaFamiliar.objFamiliar.ExistenciaFamiliar(tblfamiliar.getValueAt(i, 0).toString()) == true) {
                        frmConsultaFamiliar.objFamiliar.actualizarFamiliar();
                        if (frmConsultaFamiliar.objFamiliar.guardarFamiliarAlumno() == true) {
                            n++;
                        }
                    } else {
                        frmConsultaFamiliar.objFamiliar.guardarFamiliar();
                        if (frmConsultaFamiliar.objFamiliar.guardarFamiliarAlumno() == true) {
                            n++;
                        }
                    }
                }
         }

        if (n == tblfamiliar.getRowCount()) {
            Dialogos.GuardadoconExito();
            frmConsultaFamiliar.generartabla();
            limpiarTodo();
        } else {
            Dialogos.Error("Error al guardar los datos");
        }
    }//GEN-LAST:event_btnguardarActionPerformed

    private void btnbuscarPersonalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnbuscarPersonalActionPerformed
        dlgConsultaFamiliar familiar = new dlgConsultaFamiliar(null, true);
        familiar.setVisible(true);
    }//GEN-LAST:event_btnbuscarPersonalActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(dlgFamiliar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(dlgFamiliar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(dlgFamiliar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(dlgFamiliar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                dlgFamiliar dialog = new dlgFamiliar(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel PanelFamiliares;
    private javax.swing.JButton btnactualizar;
    private javax.swing.JButton btnagregarFamiliar;
    private javax.swing.JButton btnbuscar;
    private javax.swing.JButton btnbuscarPersonal;
    private javax.swing.JButton btnciudad;
    private javax.swing.JButton btnguardar;
    private javax.swing.JButton btnnuevo;
    private javax.swing.JButton btnocupacion;
    private javax.swing.JButton btnsalir;
    private static javax.swing.JComboBox cboParentezco;
    public static javax.swing.JComboBox cbociudadf;
    private static javax.swing.JComboBox cbofactura;
    private static javax.swing.JComboBox cbohijos;
    private static javax.swing.JComboBox cboocupacion;
    private static javax.swing.JComboBox cborepresentante;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JToolBar jToolBar4;
    private javax.swing.JTable tblfamiliar;
    public static javax.swing.JTextField txtalumno;
    private static javax.swing.JTextField txtapellidof;
    public static javax.swing.JTextField txtcedula;
    private static javax.swing.JTextField txtcedulaf;
    private static javax.swing.JTextArea txtdireccionf;
    private static javax.swing.JTextField txtlugartrabajo;
    private static javax.swing.JTextField txtmail;
    private static javax.swing.JTextField txtnombresf;
    private static javax.swing.JTextField txttelefonof;
    // End of variables declaration//GEN-END:variables
}
